import { FormItemType } from "@/components/GuatForm/types";
import {
  PointMultipleChangePropertyMap as PMCPM,
  PointTypePropertyMap as PTPM,
} from "@/map/point/property-map";
import GuatSelectMember from "@/views/attendance/duty/component/GuatSelectMember.vue";

export const baseInfoFormItemConfig: FormItemType[] = [
  {
    label: "标题",
    field: PMCPM.Title,
    component: "Input",
  },
  {
    label: "积分类型",
    field: `${PMCPM.PointType}.${PTPM.Name}`,
    component: "Select",
  },
  {
    label: "备注",
    field: PMCPM.Remark,
    component: "Textarea",
  },
];

export const addItemFormItemConfig: FormItemType[] = [
  {
    label: "标题",
    field: "title",
    component: "Input",
    required: true,
  },
  {
    label: "分值",
    field: "point",
    component: "InputNumber",
    required: true,
  },
  {
    label: "修改类型",
    field: "type",
    component: "RadioGroup",
    required: true,
    options: [
      {
        label: "加分",
        value: 0,
      },
      {
        label: "扣分",
        value: 1,
      },
    ],
  },
  {
    label: "成员名单",
    field: "memberList",
    required: true,
    render: (model) => {
      return (
        <GuatSelectMember
          selectedKeys={model.value.memberList}
          onUpdate:selectedKeys={(value) => (model.value.memberList = value)}
        />
      );
    },
  },
];

export const pointMultipleSearchForm: FormItemType[] = [
  {
    label: "名称",
    field: "name",
    component: "Input",
  },
  {
    label: "分值",
    field: "value",
    component: "InputNumber",
  },
  {
    label: "修改类型",
    field: "type",
    component: "RadioGroup",
    options: [
      {
        label: "加分",
        value: 1,
      },
      {
        label: "扣分",
        value: 2,
      },
    ],
  },
];

export const addTypeFormItemConfig: FormItemType[] = [
  {
    label: "类型名",
    field: "type",
    component: "Input",
    required: true,
  },
  {
    label: "状态",
    field: "status",
    component: "RadioGroup",
    options: [
      {
        label: "启用",
        value: 0,
      },
      {
        label: "禁用",
        value: 1,
      },
    ],
    required: true,
  },
];

export const searchFormItemConfig: FormItemType[] = [
  {
    label: "学号",
    field: "no",
    component: "Input",
    required: true,
  },
];

export const changePointFormItemConfig: FormItemType[] = [
  {
    label: "学号",
    field: "userNo",
  },
  {
    label: "积分类型",
    field: "pointType",
    component: "Select",
    required: true,
  },
  {
    label: "分值",
    field: "point",
    component: "InputNumber",
    props: {
      min: 0,
    },
    required: true,
  },

  {
    label: "修改类型",
    field: "type",
    component: "RadioGroup",
    options: [
      {
        label: "加分",
        value: 0,
      },
      {
        label: "扣分",
        value: 1,
      },
    ],
    required: true,
  },
];
